package moc.egg;
import moc.compiler.*;
import moc.tds.*;
import moc.type.*;
import moc.gc.*;
import java.util.*;
import mg.egg.eggc.runtime.libjava.lex.*;
import mg.egg.eggc.runtime.libjava.*;
import mg.egg.eggc.runtime.libjava.messages.*;
import mg.egg.eggc.runtime.libjava.problem.IProblem;
import java.util.Vector;
public class S_INST_MOC {
LEX_MOC scanner;
  S_INST_MOC() {
    }
  S_INST_MOC(LEX_MOC scanner, boolean eval) {
    this.scanner = scanner;
    this.att_eval = eval;
    this.att_scanner = scanner;
    }
int [] sync= new int[0];
  boolean att_ret;
  int att_targs;
  int att_taillev;
  int att_hdep;
  boolean att_eval;
  DTYPE att_rtype;
  String att_code;
  IMachine att_machine;
  int att_dep;
  TDS att_tds;
  LEX_MOC att_scanner;
  private void regle26() throws Exception {

    //declaration
    T_MOC x_2 = new T_MOC(scanner ) ;
    T_MOC x_3 = new T_MOC(scanner ) ;
    S_E_MOC x_5 = new S_E_MOC(scanner,att_eval) ;
    T_MOC x_6 = new T_MOC(scanner ) ;
    S_BLOC_MOC x_8 = new S_BLOC_MOC(scanner,att_eval) ;
    //appel
if  (att_eval)      action_auto_inh_26(x_5, x_8);
    x_2.analyser(LEX_MOC.token_tantque);
    x_3.analyser(LEX_MOC.token_paro);
if  (att_eval)      action_sens_26(x_5, x_8);
    x_5.analyser() ;
    x_6.analyser(LEX_MOC.token_parf);
if  (att_eval)      action_tds_26(x_5, x_8);
    x_8.analyser() ;
if  (att_eval)      action_code_26(x_5, x_8);
  }
  private void regle27() throws Exception {

    //declaration
    T_MOC x_3 = new T_MOC(scanner ) ;
    S_E_MOC x_4 = new S_E_MOC(scanner,att_eval) ;
    T_MOC x_5 = new T_MOC(scanner ) ;
    //appel
if  (att_eval)      action_auto_inh_27(x_4);
if  (att_eval)      action_sens_27(x_4);
    x_3.analyser(LEX_MOC.token_retour);
    x_4.analyser() ;
    x_5.analyser(LEX_MOC.token_pv);
if  (att_eval)      action_code_27(x_4);
  }
  private void regle28() throws Exception {

    //declaration
    T_MOC x_2 = new T_MOC(scanner ) ;
    ASM x_4 = new ASM(scanner.getReporter(), scanner.contexte);
    //appel
if  (att_eval)      action_auto_inh_28(x_4);
    x_2.analyser(LEX_MOC.token_asm);
if  (att_eval)      action_tds_28(x_4);
    x_4.scanner.setSource(scanner) ;
    x_4.set_eval(true) ;
    x_4.compile() ;
      scanner.setSource(x_4.scanner) ;
if  (att_eval)      action_gen_28(x_4);
  }
  private void regle22() throws Exception {

    //declaration
    S_BLOC_MOC x_3 = new S_BLOC_MOC(scanner,att_eval) ;
    //appel
if  (att_eval)      action_auto_inh_22(x_3);
if  (att_eval)      action_BLOCtds_22(x_3);
    x_3.analyser() ;
if  (att_eval)      action_code_22(x_3);
  }
  private void regle23() throws Exception {

    //declaration
    T_MOC x_2 = new T_MOC(scanner ) ;
    T_MOC x_3 = new T_MOC(scanner ) ;
    S_E_MOC x_5 = new S_E_MOC(scanner,att_eval) ;
    T_MOC x_6 = new T_MOC(scanner ) ;
    S_BLOC_MOC x_8 = new S_BLOC_MOC(scanner,att_eval) ;
    S_SIX_MOC x_9 = new S_SIX_MOC(scanner,att_eval) ;
    //appel
if  (att_eval)      action_auto_inh_23(x_5, x_8, x_9);
    x_2.analyser(LEX_MOC.token_si);
    x_3.analyser(LEX_MOC.token_paro);
if  (att_eval)      action_sens_23(x_5, x_8, x_9);
    x_5.analyser() ;
    x_6.analyser(LEX_MOC.token_parf);
if  (att_eval)      action_tdsBLOC_23(x_5, x_8, x_9);
    x_8.analyser() ;
    x_9.analyser() ;
if  (att_eval)      action_code_23(x_5, x_8, x_9);
  }
  private void regle20() throws Exception {

    //declaration
    S_TYPE_MOC x_2 = new S_TYPE_MOC(scanner,att_eval) ;
    T_MOC x_3 = new T_MOC(scanner ) ;
    S_AFFX_MOC x_5 = new S_AFFX_MOC(scanner,att_eval) ;
    T_MOC x_6 = new T_MOC(scanner ) ;
    //appel
if  (att_eval)      action_auto_inh_20(x_2, x_3, x_5);
    x_2.analyser() ;
    x_3.analyser(LEX_MOC.token_ident);
if  (att_eval)      action_AffType_20(x_2, x_3, x_5);
    x_5.analyser() ;
    x_6.analyser(LEX_MOC.token_pv);
if  (att_eval)      action_code_20(x_2, x_3, x_5);
  }
  private void regle21() throws Exception {

    //declaration
    S_E_MOC x_3 = new S_E_MOC(scanner,att_eval) ;
    T_MOC x_4 = new T_MOC(scanner ) ;
    //appel
if  (att_eval)      action_auto_inh_21(x_3);
if  (att_eval)      action_sens_21(x_3);
    x_3.analyser() ;
    x_4.analyser(LEX_MOC.token_pv);
if  (att_eval)      action_code_21(x_3);
  }
private void action_sens_26(S_E_MOC x_5, S_BLOC_MOC x_8) throws Exception {
try {
// instructions
x_5.att_gauche=false;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#sens","INST -> tantque paro #sens E parf #tds BLOC #code ;"});
}
  }
private void action_auto_inh_28(ASM x_4) throws Exception {
try {
// instructions
x_4.att_rtype=this.att_rtype;
x_4.att_targs=this.att_targs;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> asm #tds ASM #gen ;"});
}
  }
private void action_sens_27(S_E_MOC x_4) throws Exception {
try {
// instructions
x_4.att_gauche=false;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#sens","INST -> #sens retour E pv #code ;"});
}
  }
private void action_auto_inh_27(S_E_MOC x_4) throws Exception {
try {
// instructions
x_4.att_tds=this.att_tds;
x_4.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> #sens retour E pv #code ;"});
}
  }
private void action_auto_inh_26(S_E_MOC x_5, S_BLOC_MOC x_8) throws Exception {
try {
// instructions
x_5.att_tds=this.att_tds;
x_8.att_hdep=this.att_hdep;
x_8.att_rtype=this.att_rtype;
x_8.att_targs=this.att_targs;
x_5.att_machine=this.att_machine;
x_8.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> tantque paro #sens E parf #tds BLOC #code ;"});
}
  }
private void action_sens_23(S_E_MOC x_5, S_BLOC_MOC x_8, S_SIX_MOC x_9) throws Exception {
try {
// instructions
x_5.att_gauche=false;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#sens","INST -> si paro #sens E parf #tdsBLOC BLOC SIX #code ;"});
}
  }
private void action_sens_21(S_E_MOC x_3) throws Exception {
try {
// instructions
x_3.att_gauche=true;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#sens","INST -> #sens E pv #code ;"});
}
  }
private void action_gen_28(ASM x_4) throws Exception {
try {
// instructions
this.att_ret=x_4.att_ret_asm;
this.att_code=x_4.att_code_asm;
this.att_dep=this.att_hdep;
this.att_taillev=0;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#gen","INST -> asm #tds ASM #gen ;"});
}
  }
private void action_AffType_20(S_TYPE_MOC x_2, T_MOC x_3, S_AFFX_MOC x_5) throws Exception {
try {
// instructions
x_5.att_hisAff=true;
x_5.att_decl=true;
x_5.att_htype=x_2.att_type;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#AffType","INST -> TYPE ident #AffType AFFX pv #code ;"});
}
  }
private void action_code_21(S_E_MOC x_3) throws Exception {
try {
// instructions
this.att_code=x_3.att_code;
this.att_dep=this.att_hdep+x_3.att_etaille;
this.att_ret=false;
this.att_taillev=x_3.att_etaille;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> #sens E pv #code ;"});
}
  }
private void action_tdsBLOC_23(S_E_MOC x_5, S_BLOC_MOC x_8, S_SIX_MOC x_9) throws Exception {
try {
// instructions
if (x_5.att_type instanceof INTEGERTYPE ){
x_8.att_tds= new TDS(this.att_tds);
x_9.att_tds= new TDS(this.att_tds);
this.att_dep=this.att_hdep;
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_ErreurTypeCondition, MOCMessages.ErreurTypeCondition,new Object[]{""+x_5.att_type.toString()});


}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#tdsBLOC","INST -> si paro #sens E parf #tdsBLOC BLOC SIX #code ;"});
}
  }
private void action_code_20(S_TYPE_MOC x_2, T_MOC x_3, S_AFFX_MOC x_5) throws Exception {
try {
// locales
// instructions
if ((this.att_tds.chercherLocalement(x_3.att_txt)==null)){
if ((x_5.att_stype.equals(x_2.att_type))){
this.att_code=this.att_machine.genComment("Dedcaration de "+x_3.att_txt+"@"+this.att_hdep)+x_5.att_code;
this.att_dep=this.att_hdep+x_2.att_type.getTaille();
this.att_tds.put(x_3.att_txt,  new INFOVAR(x_2.att_type,  new Emplacement(this.att_hdep, this.att_machine.getRegister())));
this.att_taillev=x_2.att_type.getTaille();
this.att_ret=false;
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_Type_non_conformes, MOCMessages.Type_non_conformes,new Object[]{""+x_5.att_stype.toString(), ""+x_2.att_type.toString()});

}
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_deja_defini, MOCMessages.deja_defini,new Object[]{""+x_3.att_txt});

}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> TYPE ident #AffType AFFX pv #code ;"});
}
  }
private void action_code_23(S_E_MOC x_5, S_BLOC_MOC x_8, S_SIX_MOC x_9) throws Exception {
try {
// instructions
this.att_ret=x_8.att_ret||x_9.att_ret;
this.att_dep=this.att_hdep;
this.att_code=this.att_machine.genCond(x_5.att_code, x_8.att_code+this.att_machine.genPOP(x_8.att_taillev), x_9.att_code);
this.att_taillev=0;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> si paro #sens E parf #tdsBLOC BLOC SIX #code ;"});
}
  }
private void action_code_22(S_BLOC_MOC x_3) throws Exception {
try {
// instructions
this.att_ret=x_3.att_ret;
this.att_code=x_3.att_code+this.att_machine.genPOP(x_3.att_taillev);
this.att_dep=this.att_hdep;
this.att_taillev=0;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> #BLOCtds BLOC #code ;"});
}
  }
private void action_tds_26(S_E_MOC x_5, S_BLOC_MOC x_8) throws Exception {
try {
// instructions
x_8.att_tds= new TDS(this.att_tds);
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#tds","INST -> tantque paro #sens E parf #tds BLOC #code ;"});
}
  }
private void action_tds_28(ASM x_4) throws Exception {
try {
// instructions
x_4.att_tds_asm=this.att_tds;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#tds","INST -> asm #tds ASM #gen ;"});
}
  }
private void action_code_27(S_E_MOC x_4) throws Exception {
try {
// locales
DTYPE loc_t;
// instructions
loc_t=this.att_rtype;
if (loc_t instanceof VOIDTYPE ){
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_typevoid, MOCMessages.typevoid,new Object[]{});

}
else {
this.att_dep=this.att_hdep;
this.att_ret=true;
if ((x_4.att_type.equals(this.att_rtype))){
this.att_code=this.att_machine.genComment("Instruction de retour")+x_4.att_code+this.att_machine.genReturn(x_4.att_type, this.att_targs);
this.att_taillev=0;
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_Type_non_conformes, MOCMessages.Type_non_conformes,new Object[]{""+x_4.att_type.toString(), ""+this.att_rtype.toString()});

}

}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> #sens retour E pv #code ;"});
}
  }
private void action_code_26(S_E_MOC x_5, S_BLOC_MOC x_8) throws Exception {
try {
// instructions
if (x_5.att_type instanceof INTEGERTYPE ){
this.att_ret=x_8.att_ret;
this.att_code=this.att_machine.genWhile(x_5.att_code, x_8.att_code+this.att_machine.genPOP(x_8.att_taillev));
this.att_dep=this.att_hdep;
this.att_taillev=0;
}
else {
att_scanner._interrompre(IProblem.Semantic, att_scanner.getBeginLine(), IMOCMessages.id_ErreurTypeCondition, MOCMessages.ErreurTypeCondition,new Object[]{""+x_5.att_type.toString()});


}
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#code","INST -> tantque paro #sens E parf #tds BLOC #code ;"});
}
  }
private void action_auto_inh_20(S_TYPE_MOC x_2, T_MOC x_3, S_AFFX_MOC x_5) throws Exception {
try {
// instructions
x_5.att_tds=this.att_tds;
x_2.att_machine=this.att_machine;
x_5.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> TYPE ident #AffType AFFX pv #code ;"});
}
  }
private void action_auto_inh_21(S_E_MOC x_3) throws Exception {
try {
// instructions
x_3.att_tds=this.att_tds;
x_3.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> #sens E pv #code ;"});
}
  }
private void action_auto_inh_22(S_BLOC_MOC x_3) throws Exception {
try {
// instructions
x_3.att_hdep=this.att_hdep;
x_3.att_rtype=this.att_rtype;
x_3.att_targs=this.att_targs;
x_3.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> #BLOCtds BLOC #code ;"});
}
  }
private void action_BLOCtds_22(S_BLOC_MOC x_3) throws Exception {
try {
// instructions
x_3.att_tds= new TDS(this.att_tds);
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#BLOCtds","INST -> #BLOCtds BLOC #code ;"});
}
  }
private void action_auto_inh_23(S_E_MOC x_5, S_BLOC_MOC x_8, S_SIX_MOC x_9) throws Exception {
try {
// instructions
x_5.att_tds=this.att_tds;
x_8.att_hdep=this.att_hdep;
x_9.att_hdep=this.att_hdep;
x_8.att_rtype=this.att_rtype;
x_9.att_rtype=this.att_rtype;
x_8.att_targs=this.att_targs;
x_9.att_targs=this.att_targs;
x_5.att_machine=this.att_machine;
x_8.att_machine=this.att_machine;
x_9.att_machine=this.att_machine;
}catch(RuntimeException e) {       att_scanner._interrompre(IProblem.Internal,att_scanner.getBeginLine(),ICoreMessages.id_EGG_runtime_error, CoreMessages.EGG_runtime_error,new Object[] { "MOC", "#auto_inh","INST -> si paro #sens E parf #tdsBLOC BLOC SIX #code ;"});
}
  }
  public void analyser () throws Exception {
    scanner.lit ( 1 ) ;
    switch ( scanner.fenetre[0].code ) {
      case LEX_MOC.token_void : // 42
        regle20 () ;
      break ;
      case LEX_MOC.token_int : // 44
        regle20 () ;
      break ;
      case LEX_MOC.token_char : // 45
        regle20 () ;
      break ;
      case LEX_MOC.token_entier : // 69
        regle21 () ;
      break ;
      case LEX_MOC.token_chaine : // 71
        regle21 () ;
      break ;
      case LEX_MOC.token_caractere : // 70
        regle21 () ;
      break ;
      case LEX_MOC.token_plus : // 55
        regle21 () ;
      break ;
      case LEX_MOC.token_moins : // 56
        regle21 () ;
      break ;
      case LEX_MOC.token_non : // 62
        regle21 () ;
      break ;
      case LEX_MOC.token_null : // 47
        regle21 () ;
      break ;
      case LEX_MOC.token_paro : // 32
        regle21 () ;
      break ;
      case LEX_MOC.token_ident : // 72
        regle21 () ;
      break ;
      case LEX_MOC.token_mult : // 58
        regle21 () ;
      break ;
      case LEX_MOC.token_new : // 63
        regle21 () ;
      break ;
      case LEX_MOC.token_taille : // 65
        regle21 () ;
      break ;
      case LEX_MOC.token_libere : // 64
        regle21 () ;
      break ;
      case LEX_MOC.token_aco : // 34
        regle22 () ;
      break ;
      case LEX_MOC.token_si : // 39
        regle23 () ;
      break ;
      case LEX_MOC.token_tantque : // 40
        regle26 () ;
      break ;
      case LEX_MOC.token_retour : // 46
        regle27 () ;
      break ;
      case LEX_MOC.token_asm : // 43
        regle28 () ;
      break ;
      default :
               scanner._interrompre(IProblem.Syntax, scanner.getBeginLine(), IMOCMessages.id_MOC_unexpected_token,MOCMessages.MOC_unexpected_token,new String[]{scanner.fenetre[0].getNom()});
    }
  }
  }
